#!/bin/bash

DEPLOY_FILE_DIR_NAME=${JOB_BASE_NAME}_deploy
DEPLOY_FILE_DIR=${PROJECT_DIR}/jenkins_deploy/${DEPLOY_FILE_DIR_NAME}
#创建归档文件夹DEPLOY_FILE_DIR
if [ -d ${DEPLOY_FILE_DIR} ];
then
  rm -rf ${DEPLOY_FILE_DIR}
fi
mkdir -p ${DEPLOY_FILE_DIR}

cp ${PROJECT_DIR}/jenkins/jenkins-collect.sh ${DEPLOY_FILE_DIR}
cp ${PROJECT_DIR}/jenkins/jenkins-deploy.sh ${DEPLOY_FILE_DIR}
[ ${REMOTE_DEPLOY} == YES ] && cp ${PROJECT_DIR}/jenkins/jenkins-deploy-remote.sh ${DEPLOY_FILE_DIR}

#生成ini文件
CONFIG_INI_FILE=${DEPLOY_FILE_DIR}/config.ini
echo "BUILD_ID=${BUILD_ID}" > ${CONFIG_INI_FILE}
echo "module=${module}" >> ${CONFIG_INI_FILE}
echo "PROJECT_DIR=${PROJECT_DIR}" >> ${CONFIG_INI_FILE}
echo "DEPLOY_POSITION_DIR=${DEPLOY_POSITION_DIR}" >> ${CONFIG_INI_FILE}
echo "AUTO_BACKUP=${AUTO_BACKUP}" >> ${CONFIG_INI_FILE}
echo "REMOTE_DEPLOY=${REMOTE_DEPLOY}" >> ${CONFIG_INI_FILE}
echo "REMOTE_SAVE_DEPLOY_FILE=${REMOTE_SAVE_DEPLOY_FILE}" >> ${CONFIG_INI_FILE}
echo "LOCAL_SAVE_DEPLOY_FILE=${LOCAL_SAVE_DEPLOY_FILE}" >> ${CONFIG_INI_FILE}

#内部属性
echo "DEPLOY_FILE_DIR_NAME=${DEPLOY_FILE_DIR_NAME}" >> ${CONFIG_INI_FILE}